package com.study.controller.user;

import com.study.result.Result;
import com.study.service.HomepageService;
import com.study.vo.HomepageVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/user/homepage")
@Api(tags = "首页相关接口")
public class HomepageController {

    @Autowired
    HomepageService homepageService;

    /**
     * 获取首页数据
     * @return
     */
    @GetMapping("/getHomepage")
    @ApiOperation("获取首页数据")
    @Cacheable(cacheNames = "homepageCache")
    public Result<HomepageVO> getHomepage() {
        HomepageVO homepageVO =homepageService.getHomepage();
        return Result.success(homepageVO);
    }
}
